﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MadeInPortugal.Class;

namespace MadeInPortugalWebApplication
{
    public partial class DispProduct : System.Web.UI.Page
    {
        int UserId = 0;
        String UserType;
        protected override void OnInit(EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Session["UserType"] != null)
                {
                    UserType = Session["UserType"].ToString();
                    int.TryParse(Session["UserId"].ToString(), out UserId);

                    switch (Session["UserType"].ToString())
                    {
                        case "Admin":
                            Response.Redirect("AdminProductList.aspx");
                            break;
                        case "Enterprise":
                            navigationTab.Visible = true;
                            myProducts.Visible = true;
                            break;
                        case "Normal":
                            navigationTab.Visible = true;
                            myProducts.Visible = false;
                            break;
                        default:
                            navigationTab.Visible = false;
                            myProducts.Visible = false;
                            break;
                    }

                }
                else
                {
                    navigationTab.Visible = false;
                    myProducts.Visible = false;
                }
            }
        }
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            if (Session["Product"] != null)
            {
                Product prod = Session["Product"] as Product;
                liTitle.Text = prod.ProductName +" - "+prod.Enterprise.EnterpriseName;
            }
        }
    }
}
